package com.example.mybatis.controller;

import com.example.mybatis.bean.Details;
import com.example.mybatis.service.DetailsService;
import com.example.mybatis.utils.ResultUtil;
import com.example.mybatis.utils.validator.DataValidator;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("details")
public class DetailsController {
    @Resource
     DetailsService detailsService;

    @RequestMapping("selectList")
    public ResultUtil selectList(String title,Integer catalogueId) {
        return detailsService.selectList(title,catalogueId);

    }
    @RequestMapping("insert")
    public ResultUtil insert(Details details) {
        DataValidator.validator(details);
        return detailsService.insert(details);


    }

    @RequestMapping("getById")
    public ResultUtil getById(Integer id) {
        return detailsService.getById(id);


    }

    @RequestMapping("update")
    public ResultUtil update(Details details){
        return detailsService.update(details);
    }

    @RequestMapping("removeById")
    public ResultUtil removeById(Integer id){
        return detailsService.removeById(id);
    }
}



